package com.ryder.auth.domain.service.impl;

import com.ryder.auth.common.enums.IsDeleteFlagEnum;
import com.ryder.auth.domain.convert.AuthRoleBOConvert;
import com.ryder.auth.domain.entity.AuthRoleBO;
import com.ryder.auth.domain.service.AuthRoleDomainService;
import com.ryder.auth.infra.basic.entity.AuthRole;
import com.ryder.auth.infra.basic.service.AuthRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 描述: 角色信息表(AuthRoleDomain)表服务实现类
 *
 * @author Ryder
 * @version 1.0
 * @since 1.0 // 版本号，指明从哪个版本开始
 * 更新日期: 2025-02-17 19:47:51
 */
@Service
public class AuthRoleDomainServiceImpl implements AuthRoleDomainService {

    @Autowired
    private AuthRoleService authRoleService;

    @Override
    public Boolean add(AuthRoleBO authRoleBO) {
        AuthRole authRole = AuthRoleBOConvert.INSTANCE.convertBoToEntity(authRoleBO);
        authRole.setIsDeleted(IsDeleteFlagEnum.UN_DELETED.getCode());
        Integer count = authRoleService.insert(authRole);
        return count > 0;
    }

    @Override
    public Boolean update(AuthRoleBO authRoleBO) {
        AuthRole authRole = AuthRoleBOConvert.INSTANCE.convertBoToEntity(authRoleBO);
        Integer count = authRoleService.update(authRole);
        return count > 0;
    }

    @Override
    public Boolean delete(AuthRoleBO authRoleBO) {
        AuthRole authRole = new AuthRole();
        authRole.setId(authRoleBO.getId());
        authRole.setIsDeleted(IsDeleteFlagEnum.DELETED.getCode());
        Integer count = authRoleService.update(authRole);
        return count > 0;
    }
}
